/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.vienthonga.homepage.action;

import com.vienthonga.hibernate.pojo.TProduct;
import com.vienthonga.hibernate.pojo.TSupplier;
import com.vienthonga.homepage.logic.HomePageLogic;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author DoanHa
 */
public class HomePageAction extends Action {

    private static final Logger logger = Logger.getLogger(
            HomePageAction.class.getName());
    private static final String SUCCESS = "success";

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        logger.log(Level.INFO, mapping.getPath());

        //Lay du lieu cac nha san xuat
        HomePageLogic logic = new HomePageLogic();
        List<TProduct> newMobilephones = logic.getNewMobilephone();

         //lay du lieu cac san pham thong dung
        List<TProduct> normalMobilephones = logic.getNormalMobilephone();

        //lay du lieu cac san pham trung cap
        List<TProduct> mediumMobilephones = logic.getMediumMobilephone();

        //lay du lieu cac san pham cao cap
        List<TProduct> highMobilephones = logic.getHighMobilephone();

          //lay du lieu cac san pham sieu cap
        List<TProduct> superMobilephones = logic.getSuperMobilephone();

        request.setAttribute("NewMobilephone", newMobilephones);
        request.setAttribute("NormalMobilephone", normalMobilephones);
        request.setAttribute("MediumMobilephone", mediumMobilephones);
        request.setAttribute("HighMobilephone", highMobilephones);
        request.setAttribute("SuperMobilephone", superMobilephones);

        return mapping.findForward(SUCCESS);
    }
}
